#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <math.h>
#include <stdlib.h>
#include <stdio.h>

#define DEBUG 0
#define NOISY_TEST 1

int checkwhoseTurn(struct gameState *post) {
  struct gameState pre;
  memcpy (&pre, post, sizeof(struct gameState));

  int r, turn;
  r =  whoseTurn(post);
  turn = pre.whoseTurn;


  assert (r == turn);

  assert(memcmp(&pre, post, sizeof(struct gameState)) == 0);
  return 0;
}

int main () {

  int n, p;
  struct gameState G;
  printf ("Testing whoseTurn.\n");

  printf ("RANDOM TESTS.\n");

  SelectStream(2);
  PutSeed(3);
  
  for (n = 0; n < 2000; n++) {
    p = floor(Random() * MAX_PLAYERS);
    G.whoseTurn = p;
    checkwhoseTurn(&G);
  }



  printf ("SIMPLE FIXED TESTS.\n");
  for (p = 0; p < MAX_PLAYERS; p++) {
     G.whoseTurn = p;
     checkwhoseTurn(&G);  
  }
  
  printf ("ALL TESTS OK\n");

  return 0;
}
